﻿<UserControl x:Class="Astor.Modules.DataSources.Screens.List.DataSourceListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:prism="http://www.codeplex.com/prism" 
    xmlns:module="clr-namespace:Astor.Modules.DataSources"
    xmlns:details="clr-namespace:Astor.Modules.DataSources.Screens.Details"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    mc:Ignorable="d"
    d:DesignHeight="300" Width="251">
    <UserControl.Resources>
        <module:DesignDatalLocator x:Key="designDataLocator" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" d:DataContext="{Binding Source={StaticResource designDataLocator}, Path=DataSourceListViewModel}">
        <i:Interaction.Triggers>
            <prism:InteractionRequestTrigger SourceObject="{Binding DeleteRequest}">
                <prism:PopupChildWindowAction  />
            </prism:InteractionRequestTrigger>

            <prism:InteractionRequestTrigger SourceObject="{Binding DetailsRequest}">
                <prism:PopupChildWindowAction>
                    <prism:PopupChildWindowAction.ChildWindow>
                        <details:DataSourceDetailsView />
                    </prism:PopupChildWindowAction.ChildWindow>
                </prism:PopupChildWindowAction>
            </prism:InteractionRequestTrigger>
        </i:Interaction.Triggers>
        
        

        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
            <Button x:Name="Add" Content="Add" HorizontalAlignment="Left" Width="75" Command="{Binding AddCommand, Mode=OneWay}"/>
            <Button x:Name="Edit" Content="Modify" HorizontalAlignment="Left" Width="75" Command="{Binding EditCommand, Mode=OneWay}"/>
            <Button x:Name="Delete" Content="Delete" HorizontalAlignment="Left" Width="75" Command="{Binding DeleteCommand, Mode=OneWay}"/>
        </StackPanel>

        <ListBox Grid.Row="1" ItemsSource="{Binding DataSources}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedDataSource, Mode=TwoWay}" />
        
    </Grid>
</UserControl>
